package com.study.configuration;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.support.TransactionTemplate;

public class TransactionTemplateConfiguration {

    @Autowired
    DataSourceTransactionManager dataSourceTransactionManager;

    /*配置事务管理的模板*/
    @Bean(name = "transactionTemplate")
    public TransactionTemplate createTransactionTemplate() {
        TransactionTemplate transactionTemplate = new TransactionTemplate();
        transactionTemplate.setTransactionManager(dataSourceTransactionManager);
        return transactionTemplate;
    }

}
